<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增角色')" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-gitee-add" th:object="${giteeAddress}">
		<input type="hidden" id="logged" name="logged" value="1" class="form-control" placeholder="请输入文本">
		<input type="hidden" id="gitline" name="gitline" value="1" class="form-control" placeholder="请输入文本">
		<input id="configId" name="id" th:field="*{id}"  type="hidden">
		<div class="col-md-12">
			<div class="form-group">
				<label class="col-sm-3 control-label">项目名称：</label>
				<div class="col-sm-9">
					<input type="text" name="gitee" th:field="*{gitee}" class="form-control" placeholder="请输入文本" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">项目地址：</label>
				<div class="col-sm-9">
					<input type="text" name="address" th:field="*{address}" class="form-control" placeholder="请输入文本">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">是否上线：</label>
				<div class="col-sm-9">
					<label class="toggle-switch switch-solid">
						<input type="checkbox" onclick="" id="status" checked>
						<span onclick="logged(1)"></span>
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">是否为Git项目：</label>
				<div class="col-sm-9">
					<label class="toggle-switch switch-solid">
						<input type="checkbox" id="status" checked>
						<span onclick="gitline(1)"></span>
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">图片地址：</label>
				<div class="col-sm-9">
					<input type="text" name="picture" th:field="*{picture}" class="form-control" placeholder="请输入文本">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">项目简介：</label>
				<div class="col-sm-9">
					<input type="text" name="brief" th:field="*{brief}" class="form-control" placeholder="请输入文本">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">预售价：</label>
				<div class="col-sm-9">
					<input type="text" name="price" th:field="*{price}" class="form-control" placeholder="请输入文本">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">项目大小(Mb)：</label>
				<div class="col-sm-9">
					<input type="text" name="projectsize" th:field="*{projectsize}" class="form-control" placeholder="请输入文本">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-12 col-sm-offset-3">
					<button type="submit" onclick="add()" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>

		</div>
	</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">
	function submitHandler() {
		if ($.validate.form()) {
			add();
		}
	}
	function logged(id){

		if($("#logged").val()==='1'){
			$("#logged").val('0');
			console.log($(" input[ id='logged' ] ").val());
		}else{
			$("#logged").val('1');
			console.log($(" input[ id='logged' ] ").val());
		}
	}
	function gitline(id){

		if($("#gitline").val()==='1'){
			$("#gitline").val('0');
			console.log($(" input[ id='gitline' ] ").val());
		}else{
			$("#gitline").val('1');
			console.log($(" input[ id='gitline' ] ").val());
		}
	}
	function add() {
		var gitee = $("input[name='gitee']").val();
		var address = $("input[name='address']").val();
		var logged = $("input[name='logged']").val();
		var gitline = $("input[name='gitline']").val();
		var picture = $("input[name='picture']").val();
		var brief = $("input[name='brief']").val();
		var price = $("input[name='price']").val();
		var projectsize = $("input[name='projectsize']").val();
		var id = $("input[name='id']").val();
		$.ajax({
			cache : true,
			type : "POST",
			url : ctx + "system/gitee/edit",
			data : {
				"gitee": gitee,
				"address": address,
				"logged": logged,
				"gitline": gitline,
				"picture": picture,
				"brief": brief,
				"price": price,
				"projectsize": projectsize,
				"id": id
			},
			async : false,
			error : function(request) {
				$.modal.alertError("系统错误");
			},
			success : function(data) {
				$.operate.successCallback(data);
			}
		});
	}
</script>
</body>
</html>
